import { defHttp } from '../http'
import type {
  NodeParams,
  NodeGroupParams,
  DeleteGroups,
  CreateGroupParams,
  updateMultipleStatus,
  DeleteNodes,
  EditSingleNode,
  singleNode
} from '../model/node'
import type { BaseListResp } from './response'

/** 节点列表 */
export const node_list = (params: NodeParams) =>
  defHttp.get<BaseListResp<any>>('/v1/node', { params })
/** 编辑单个节点信息 */
export const update_node = (params: EditSingleNode) =>
  defHttp.put<BaseListResp<any>>(`/v1/node/${params.id}`, { params })
/** 获取单个节点信息 */
export const get_node = (params: singleNode) =>
  defHttp.get<BaseListResp<any>>(`/v1/node/${params.id}`)
/** 删除单个节点 */
export const delete_single_node = ({ id }) =>
  defHttp.delete<BaseListResp<any>>(`/v1/node/${id}`)
/** 删除多个节点*/
export const delete_nodes = (params: DeleteNodes) =>
  defHttp.delete<BaseListResp<any>>('/v1/nodes', { params })
/** 节点分组 */
export const node_group = (params: NodeGroupParams) =>
  defHttp.get<BaseListResp<any>>('/v1/node_group', { params })
/** 删除单个分组 */
export const delete_single_group = ({ id }) =>
  defHttp.delete<BaseListResp<any>>(`/v1/node_group/${id}`)
/** 删除多个分组*/
export const delete_groups = (params: DeleteGroups) =>
  defHttp.delete<BaseListResp<any>>('/v1/node_groups', { params })
/** 创建节点分组 */
export const create_group = (params: CreateGroupParams) =>
  defHttp.post<BaseListResp<any>>('/v1/node_group', { params })
/** 更新节点分组  */
export const update_group = (params: CreateGroupParams) =>
  defHttp.put<BaseListResp<any>>(`/v1/node_group/${params.id}`, { params })
/** 更新单个节点状态  */
export const update_single_status = (params: any) =>
  defHttp.delete<BaseListResp<any>>(`/v1/node/${params.id}`, { params })
/** 更新多个节点状态  */
export const update_multiple_status = (params: updateMultipleStatus) =>
  defHttp.delete<BaseListResp<any>>(`/v1/nodes`, { params })
